<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    
</body>
<script>
    /* 浅拷贝： 拷贝成为新的一份，而不是简单的复制 */
    var obj = {name: '张阿三', age: 13};
    var arr = [2, 'r', 78, 'op'];
    var obj1 = {...obj};
    var arr1 = [...arr];
    // console.log(obj === obj1);//false

    /* 原生代码实现浅拷贝 */
    // let newObj = {}
    // for (key in obj) {
    //     newObj[key] = obj[key];
    // }
    // console.log(newObj)
    let newArr = [];
    for (key in arr) {
        newArr[key] = arr[key];
    }
    console.log(newArr);
</script>
</html>